import { notification } from 'antd';

const notifications = {
  e(title: string, msg?: string, duration?: number) {
    showNotification(title, msg, duration, 'error');
  },

  i(title: string, msg?: string, duration?: number) {
    showNotification(title, msg, duration, 'info');
  },

  s(title: string, msg?: string, duration?: number) {
    showNotification(title, msg, duration, 'success');
  },
};
function showNotification(
  title: string,
  msg: string,
  duration?: number,
  type?: 'info' | 'success' | 'warn' | 'error'
) {
  const option = {
    message: (
      <section>
        <h3>{title}</h3>
        {msg && <p>{msg}</p>}
      </section>
    ),
    duration
  }
  notification[type || 'info'](option)
}

export default notifications;
